-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Config Service] Expose serverless
contextRef
#156837
[Config Service] Expose serverless
contextRef
#156837
Conversation
Documentation preview: |
@@ -241,6 +241,7 @@ export class ConfigService { | |||
{ | |||
dev: this.env.mode.dev, | |||
prod: this.env.mode.prod, | |||
serverless: this.env.cliArgs.serverless === true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's optional, so I thought it's safer to validate it's true
.
startKibana: async (abortSignal?: AbortSignal) => { | ||
const root = createRootWithCorePlugins(kbnSettings, cliArgs); | ||
|
||
abortSignal?.addEventListener('abort', async () => await root.shutdown()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed this so I could stop Kibana when left hanging waiting for a valid ES connection
@@ -97,8 +97,7 @@ export class ElasticsearchService | |||
const esNodesCompatibility$ = pollEsNodesVersion({ | |||
internalClient: this.client.asInternalUser, | |||
log: this.log, | |||
ignoreVersionMismatch: | |||
config.ignoreVersionMismatch || this.coreContext.env.cliArgs.serverless === true, | |||
ignoreVersionMismatch: config.ignoreVersionMismatch, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Back to not checking explicitly for serverless in this part of the code... 💆
enabled: schema.boolean({ defaultValue: schema.contextRef('dev') }), | ||
|
||
// Setting only allowed in the Serverless offering | ||
plansForWorldPeace: schema.conditional( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was tempted with plansForWorldDomination
, but I toned it down a bit 😅
// When running in serverless mode, default to `true` | ||
defaultValue: schema.contextRef('serverless'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about nesting another conditional but found this solution a bit cleaner. Happy to iterate if you think it's best to have the explicit conditional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine as long as we're absolutely certain there aren't any other valid use cases where the version mismatch doesn't matter. If we're not certain, then a nested conditional is safer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, fine for now ihmo, we can change later if needed.
@@ -68,7 +68,6 @@ function createFakeElasticsearchServer() { | |||
return server; | |||
} | |||
|
|||
// FLAKY: https://github.com/elastic/kibana/issues/129754 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left over: no longer flaky
0998c4c
to
414cb69
Compare
414cb69
to
ea011c9
Compare
Pinging @elastic/kibana-core (Team:Core) |
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/kbn-test
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation looks fine. I added a couple of comments/questions I'd like your input on first please.
}); | ||
await Promise.race([ | ||
firstValueFrom(found$), | ||
startServers({ customKibanaVersion: nextMinor() }).then(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test only asserts against version mismatch between x.n and x.n+1. We should test against a mismatch between x.n and x.n-1 too.
Can we assume mismatches between current and previous/next patches won't matter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test only asserts against version mismatch between x.n and x.n+1. We should test against a mismatch between x.n and x.n-1 too
Kibana "is compatible" with newer minor versions of ES already:
Lines 29 to 39 in 3508350
// Reject mismatching major version numbers. | |
if (esVersionNumbers.major !== kibanaVersionNumbers.major) { | |
return false; | |
} | |
// Reject older minor versions of ES. | |
if (esVersionNumbers.minor < kibanaVersionNumbers.minor) { | |
return false; | |
} | |
return true; |
(which is unitary tested in the associated test file), so I'd say it's fine to only test the other scenario?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's good to have an integration test for the "ES is next minor" use case to catch any potential regressions in the future.
I added it in d4e619a
(#156837)
Thank you for raising it, @TinaHeiligers
plansForWorldPeace: schema.conditional( | ||
schema.contextRef('serverless'), | ||
true, | ||
schema.string({ defaultValue: 'Kill all humans' }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: We should probably avoid that kind of word / sentence in our repo :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I toned it down here: 859e3e1
(#156837)
// When running in serverless mode, default to `true` | ||
defaultValue: schema.contextRef('serverless'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, fine for now ihmo, we can change later if needed.
}); | ||
await Promise.race([ | ||
firstValueFrom(found$), | ||
startServers({ customKibanaVersion: nextMinor() }).then(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test only asserts against version mismatch between x.n and x.n+1. We should test against a mismatch between x.n and x.n-1 too
Kibana "is compatible" with newer minor versions of ES already:
Lines 29 to 39 in 3508350
// Reject mismatching major version numbers. | |
if (esVersionNumbers.major !== kibanaVersionNumbers.major) { | |
return false; | |
} | |
// Reject older minor versions of ES. | |
if (esVersionNumbers.minor < kibanaVersionNumbers.minor) { | |
return false; | |
} | |
return true; |
(which is unitary tested in the associated test file), so I'd say it's fine to only test the other scenario?
@elasticmachine merge upstream |
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Public APIs missing comments
Unknown metric groupsAPI count
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @afharo |
## 📓 Summary Closes #157042 After the implementation of #156837, we are now able to limit the `logs.app_target` configuration to be accepted only in a serverless environment, otherwise, it'll not be accepted. Since we still need to use a default fallback value for the logs UI app, the fallback will be applied internally when looking for this config, to keep the original behaviour unchanged. ## 🧪 Testing ### Serverless environment - Start Elasticsearch with `yarn es snapshot` and Kibana with `yarn serverless-oblt` - Verify that when navigating to Logs pages through the sidebar links or directly accessing the url `/app/logs` it redirects to discover. ### Normal environment - Start Elasticsearch with `yarn es snapshot` and Kibana with `yarn start` - Verify that when navigating to Logs pages through the sidebar links or directly accessing the url `/app/logs` the log stream is rendered correctly. ### Limited to serverless env To verify that the configuration is only accepted under a serverless context, set into your kibana.yml or `kibana.dev.yml` the configuration ```yml xpack.infra.logs.app_target: discover ``` and verify that it triggers a validation error when running Kibana. --------- Co-authored-by: Marco Antonio Ghiani <[email protected]> Co-authored-by: Kibana Machine <[email protected]>
Summary
Resolves #152395.
We need to expose some configuration to be available only when Kibana is running in Serverless offering. This PR adds the
schema.contextRef('serverless')
for developers to validate their settings based on this new context.This PR also extends some documentation around the
schema.contextRef
API and uses the new context reference in the Elasticsearch service to define the defaults inelasticsearch.ignoreVersionMismatch
.Checklist
Risk Matrix
isServerless
API by setting a conditional config entry based on the newserverless
context referenceFor maintainers